import { BrowserRouter as Router, Route, Link, NavLink, Switch } from "react-router-dom";

const Home = () => {
  return <div>Home组件</div>
}
const First = () => {
  return <div>First组件</div>
}

const App = () => {
  // react-router-dom 使用 5.3.0 版本
  // 核心组件：Router(HashRouter，BrowserRouter) Route Link
  // Router 包裹根组件
  // Link  导航菜单
  return (
    <Router>
      <div className="app">
        <h1>根组件</h1>
      </div>
      <ul>
        <li>
          <Link to="/">首页</Link>
        </li>
        <li>
          <Link to="/first">页面一</Link>
        </li>
      </ul>
      {/* 路由规则 */}
      {/* 让Route组件被匹配的第一个组件渲染，其他不渲染 */}
      <Switch>
        <Route path="/" exact component={Home}></Route>
        <Route path="/first" component={First}></Route>
        <Route>
          404页面
        </Route>
      </Switch>
    </Router>
  );
};

export default App;
